#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2020/11/12 14:12
# @Author : luhongxuan
# @Site :
# @File : yaml_utils.py
# @Software: PyCharm
import yaml


class YAMLHelper(object):
    @staticmethod
    def read_from_yaml(path):
        with open(path, 'rb') as f:
            file_data = f.read()
            # yaml文件通过---分节，多个节组合成一个列表
        data = yaml.safe_load_all(file_data)

        return list(data)

    @staticmethod
    def write_to_yaml(path, data, mode='w'):
        with open(path, mode) as f:
            yaml.dump(data, f)
